package com.dzk.cp.c11x5.index.q2.hz.yl;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.dzk.cp.c11x5.index.BaseC11x5Index;
import com.dzk.cp.c11x5.pojo.R5;
import com.dzk.cp.c11x5.util.SpringBeanUtils;

public abstract class Q2HZnYLIndex extends BaseC11x5Index {
	
	private int hz;
	
	protected Q2HZnYLIndex setParams(int code, int num, int unit, int hz) {
		super.setParams(code, num, unit);
		this.hz = hz;
		return this;
	}

	@Override
	public Map<?, Integer> index() {
		Map<Integer, Integer> resultMap = new LinkedHashMap<Integer, Integer>();
		int n = getLastestNum();
		List<? extends R5> r5s = SpringBeanUtils.getR5Service(code).queryLatest(n);
		int i = -1, j = 0, k = 0;
		for (; k < n; k++) {
			R5 r5 = r5s.get(k);
			if (r5.getN1() + r5.getN2() == hz) {
				resultMap.put(++j, k - i - 1);
				i = k;
			}
		}
		resultMap.put(++j, k - 1 - i);
		return resultMap;
	}
	
	public static Q2HZnYLIndex getInstance(int code, int num, int unit, int hz) {
		switch (hz) {
		case 3:
			return new Q2HZ3YLIndex().setParams(code, num, unit, hz);
		case 4:
			return new Q2HZ4YLIndex().setParams(code, num, unit, hz);
		case 5:
			return new Q2HZ5YLIndex().setParams(code, num, unit, hz);
		case 6:
			return new Q2HZ6YLIndex().setParams(code, num, unit, hz);
		case 7:
			return new Q2HZ7YLIndex().setParams(code, num, unit, hz);
		case 8:
			return new Q2HZ8YLIndex().setParams(code, num, unit, hz);
		case 9:
			return new Q2HZ9YLIndex().setParams(code, num, unit, hz);
		case 10:
			return new Q2HZ10YLIndex().setParams(code, num, unit, hz);
		case 11:
			return new Q2HZ11YLIndex().setParams(code, num, unit, hz);
		case 12:
			return new Q2HZ12YLIndex().setParams(code, num, unit, hz);
		case 13:
			return new Q2HZ13YLIndex().setParams(code, num, unit, hz);
		case 14:
			return new Q2HZ14YLIndex().setParams(code, num, unit, hz);
		case 15:
			return new Q2HZ15YLIndex().setParams(code, num, unit, hz);
		case 16:
			return new Q2HZ16YLIndex().setParams(code, num, unit, hz);
		case 17:
			return new Q2HZ17YLIndex().setParams(code, num, unit, hz);
		case 18:
			return new Q2HZ18YLIndex().setParams(code, num, unit, hz);
		case 19:
			return new Q2HZ19YLIndex().setParams(code, num, unit, hz);
		case 20:
			return new Q2HZ20YLIndex().setParams(code, num, unit, hz);
		case 21:
			return new Q2HZ21YLIndex().setParams(code, num, unit, hz);
		default:
			return null;
		}
	}

}

class Q2HZ3YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 1;
	}
	
}

class Q2HZ4YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 1;
	}
	
}

class Q2HZ5YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 2;
	}
	
}

class Q2HZ6YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 2;
	}
	
}

class Q2HZ7YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 3;
	}
	
}

class Q2HZ8YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 3;
	}
	
}

class Q2HZ9YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 4;
	}
	
}

class Q2HZ10YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 4;
	}
	
}

class Q2HZ11YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 5;
	}
	
}

class Q2HZ12YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 5;
	}
	
}

class Q2HZ13YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 5;
	}
	
}

class Q2HZ14YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 4;
	}
	
}

class Q2HZ15YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 4;
	}
	
}

class Q2HZ16YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 3;
	}
	
}

class Q2HZ17YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 3;
	}
	
}

class Q2HZ18YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 2;
	}
	
}

class Q2HZ19YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 2;
	}
	
}

class Q2HZ20YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 1;
	}
	
}

class Q2HZ21YLIndex extends Q2HZnYLIndex {

	@Override
	protected int getZQ() {
		return 55 / 1;
	}
	
}
